package main

import (
	"io/ioutil"
	"log"
	"nick-gingin/bootstrap"
	"nick-gingin/config"
	"nick-gingin/global"
	"nick-gingin/route"
	"nick-gingin/test"

	"github.com/gin-gonic/gin"
	"gopkg.in/yaml.v2"
)

func main() {

	test.Nick()

	yamlFile, err := ioutil.ReadFile("config/config.yaml")
	if err != nil {
		log.Fatalf("error: %v", err)
	}

	// 解析YAML数据到结构体
	var config config.Configuration

	err = yaml.Unmarshal(yamlFile, &config)
	if err != nil {
		log.Fatalf("error: %v", err)
	}

	// 初始化数据库
	global.App.DB = bootstrap.InitializeDB()

	gin.SetMode(gin.ReleaseMode)
	r := gin.Default()
	route.Init(r)
	r.Run("127.0.0.1:8080")
}
